package com.doudou.feign.auth.transmit;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/**
 * @Author: 傻男人
 * @Date: 2020/5/25 11:28
 * @Version: 1.0
 * @Description: 只是为打印头部是否有token的参数
 */
@Slf4j
public class RequestFilter implements Filter {

    public RequestFilter() {

    }
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
    }
    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        String token = ((HttpServletRequest)request).getHeader("Authorization");
        if (StringUtils.isNotBlank(token)) {
            log.info("---------------获取的token-----------------------------");
            log.info(token);
            log.info("------------------------------------------------------");
        }
       chain.doFilter(request,response);
    }

    @Override
    public void destroy() {
    }
}
